#!/usr/bin/python

import MySQLdb
import sys
import logic
from utility import *
import db_info

db = MySQLdb.connect(host=db_info.DB_HOST, user=db_info.DB_USERNAME, passwd=db_info.DB_PASSWORD, db=db_info.DB_DATABASE)

if len(sys.argv) >= 2:
    sentences = sys.argv[1]
else:
    sentences = sys.stdin.read()
sentences = sentences.splitlines()
for sentence in sentences:
    if start_with(sentence, "#"):
        continue
    result = logic.process_sentence(sentence, db)
    print result
    
